package com.android.nurse;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.Button;

public class NjbScreen extends CommonActivity {
	private Button btnSiteNJB;
	private Button btnBackTop;
	private int width;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Display display = ((WindowManager) this
				.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
		width = display.getWidth();
		Log.d("chieu rong man hinh", ""+width);
		if(width > 500){
			setContentView(R.layout.njbscreen_big);
		} else {
		setContentView(R.layout.njbscreen);
		}
		btnSiteNJB = (Button) findViewById(R.id.btnSiteNJB);
		btnBackTop = (Button) findViewById(R.id.btnBackTop);
		
		myThread.start();
	}


	private Thread myThread = new Thread(new Runnable() {

		@Override
		public void run() {

			synchronized (this) {
				try {
					btnBackTop.setClickable(false);
					wait(500);
					btnBackTop.setClickable(true);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
			setOnClick();
		}
	});
	
	private void setOnClick(){
		btnSiteNJB.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				final Intent intent = new Intent(Intent.ACTION_VIEW)
						.setData(Uri
								.parse("http://tr.webantenna.info/rd?waad=dQxJ5Fks&ga=WAFE8v-1"));
				startActivity(intent);
			}
		});

		btnBackTop.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent(getApplicationContext(), TopScreen.class);
				backScreen(i);
			}
		});
	}
	@Override
	protected void onRestart() {
		super.onRestart();
		Intent i = new Intent(getApplicationContext(), TopScreen.class);
		TopScreen.updateTimes = 0;
		startActivity(i);
	}
	@Override
	public void onBackPressed() {
	   return;
	}
}
